<?php 
		echo $this->Html->script('admin.user');
		$config = Configure::getInstance();
?>

		<div class="pagination">
			<div class="paging">

				<?php 
				if(!$this->Paginator->first()){
				?>
				<span class="arrowBg grayPrevFirst" href="#"></span>
				<?
				}
				echo $this->Paginator->first('<span class="arrowBg yellowPrevFirst"></span>', array('escape'=>false));
										
				if($this->Paginator->hasPrev()){
					echo $this->Paginator->prev('<span class="arrowBg yellowPrev"></span>', array('escape'=>false));
				}
				else{
					echo $this->Paginator->prev('<span class="arrowBg grayPrev"></span>', array('escape'=>false));
				}
				?>
				<?php echo $this->Paginator->numbers();?>
				<?php 
					if($this->Paginator->hasNext()){
					
						echo $this->Paginator->next('<span class="arrowBg yellowNext"></span>', array('escape'=>false));
					}
					else{
						echo $this->Paginator->next('<span class="arrowBg grayNext"></span>', array('escape'=>false));
					}
				if(!$this->Paginator->last()){
				?>
				<span class="arrowBg grayNextFirst"></span>
				<?
				}		
					echo $this->Paginator->last('<span class="arrowBg yellowNextFirst"></span>', array('escape'=>false));
				?>
			</div>
		</div>
		
		
		<div id='togglestatusurl' style="display:none;"><?php  echo $this->webroot."admin/". $this->params['controller'] ."/togglestatus"?></div>
					
		
			<div class="memberEdit">
					<table cellpadding="0" cellspacing="0" border="0" width="100%">
							<tr>
								<th><?php echo $this->Paginator->sort('id');?></th>
								<th ><?php echo $this->Paginator->sort('name');?></th>
								<th>Username</th>								
								<th >Roles</th>
								<th  width="10%">Delete</th>
							</tr>
							
							<?php
							if($dataempty){
							?>
								<tr class="altBg">
									<td>No Data Found.</td>
								</tr>
							<?
							}
							$i=1;
							foreach ($users as $user):
								if($i%2==0) $class='thTableEvenRow';
								else $class='thTableOddRow';
							?>
							
							<tr class="<?=$class?>">
								<td><?php echo $user['User']['id'];?></td>
								<td><?php echo $user['User']['name'];?></td>
								<td><?php echo $user['User']['username'];?></td>
								
								<? 
								$status = $user['User']['status']; 
								$options = $config->roles;
								// $cmdchangerole = "<a id='ts". $user['User']['id']."' href='javascript:togglestatus(".$user['User']['id'] . ")'  class='underline'  >$statustext</a> ";
								?>
								
								<td><?php echo $this->Form->select('role', $options, array('value' => $user['User']['role']), array('empty' => false, 'class' => 'user_role', 'user_id' => $user['User']['id'])); ?></td>
								
								<td class="actions">
									<a href="<?php echo $this->Html->url(array('action' => '/delete/'.$user['User']['id']) ); ?>" onclick="return confirm('Are you sure you want to delete user : <?php echo $user['User']['username'] ?>?');"><img src="<?php echo $html->url('/') ?>img/iconDel.gif" alt="Delete" /></a>
								</td>
								
							</tr>
							<?php 
							$i++;
							endforeach; ?>
						</table>
			</div>
			
			
		<div class="pagination">
			<div class="paging">

				<?php 
				if(!$this->Paginator->first()){
				?>
				<span class="arrowBg grayPrevFirst" href="#"></span>
				<?
				}
				echo $this->Paginator->first('<span class="arrowBg yellowPrevFirst"></span>', array('escape'=>false));
										
				if($this->Paginator->hasPrev()){
					echo $this->Paginator->prev('<span class="arrowBg yellowPrev"></span>', array('escape'=>false));
				}
				else{
					echo $this->Paginator->prev('<span class="arrowBg grayPrev"></span>', array('escape'=>false));
				}
				?>
				<?php echo $this->Paginator->numbers();?>
				<?php 
					if($this->Paginator->hasNext()){
					
						echo $this->Paginator->next('<span class="arrowBg yellowNext"></span>', array('escape'=>false));
					}
					else{
						echo $this->Paginator->next('<span class="arrowBg grayNext"></span>', array('escape'=>false));
					}
				if(!$this->Paginator->last()){
				?>
				<span class="arrowBg grayNextFirst"></span>
				<?
				}		
					echo $this->Paginator->last('<span class="arrowBg yellowNextFirst"></span>', array('escape'=>false));
				?>
			</div>
		</div>